/**
 * Created by znsw007 on 2015/12/22.
 */

/**
 *模版管理工具
 */
var tplManager = {
    init:function(){
        this.getGlobalTpl();
    },
    getGlobalTpl:function(){
        $$.get('tpl/inner.tpl.html',function(html){
            $$('body').append(html);
        });
    },
    loadTpl:function(id){
        // console.log(id)
        var tpl = $$("#"+id).html();
        // console.log(tpl)
        return tpl;
    },
    renderRemoteTpl:function(tplName,renderData,callback){
        var that = this;
        tplName = tplName ||'';
        $$.get('tpl/'+tplName+".html",function(markup){
            var output = that.renderTpl(markup,renderData);
            typeof(callback === 'function') ? callback(output) : null;
        });
    },
    renderTpl: function(markup,renderData){
        var compiledTemplate = T7.compile(markup);
        var output = compiledTemplate(renderData);
        return output;
    },
    renderTplById: function(tplId,renderData){
        var markup = this.loadTpl(tplId);
        return this.renderTpl(markup,renderData);
    }
};

